/***********************************************************************************/
/* Code license:  GNU General Public License v3                                    */
/* Main page:     https://code.google.com/p/library-cross-platform/                */
/* Issue tracker: https://code.google.com/p/library-cross-platform/issues/list     */
/***********************************************************************************/

#ifndef _UNARY_FUNCTIONS_10_JUN_2011_
#define _UNARY_FUNCTIONS_10_JUN_2011_

#include <algorithm>
#include <functional>

using namespace std;

template<class T> struct eof_string : public unary_function<T, bool> {
  public:
   bool operator() (const T& x) const {
     return (x == '\n' || x == '\r') ? true : false;
   }
};

template<class T> struct is_null_char : public unary_function<T, bool> {
  public:
   bool operator() (const T& x) const {
     return (x == '\0') ? true : false;
   }
};

template<class T> struct is_space_char : public unary_function<T, bool> {
  public:
   bool operator() (const T& x) const {
     return (x == ' ') ? true : false;
   }
};

template<class T> struct is_end_of_line : public unary_function<T, bool> {
  public:
   bool operator() (const T& x) const {
     return (x == '\0' || x == '\n' || x == '\r') ? true : false;
   }
};

/**
  Check is "Carriage return" (CR) '\r' or '0x0D' (13 in decimal)
*/
template<class T> struct is_cr : public unary_function<T, bool> {
  public:
   bool operator() (const T& x) const {
     return (x == '\r') ? true : false;
   }
};

/**
  Check is "Line Feed" (LF). '\n' or '0x0A' (10 in decimal)
*/
template<class T> struct is_lf : public unary_function<T, bool> {
  public:
   bool operator() (const T& x) const {
     return (x == '\n') ? true : false;
   }
};




#endif //_UNARY_FUNCTIONS_10_JUN_2011_
